#ifndef __CMD_SELECT_DATA_FROM_DB_H__
#define __CMD_SELECT_DATA_FROM_DB_H__

#include "commmsg.h"
#include "CTAsyncCmd.h"

class CDBCtrl;
class CCmdSQL;
class CCmdSelectDataFromDB : public CTLib::CTAsyncCmd
{
public:
    CCmdSelectDataFromDB();
    virtual ~CCmdSelectDataFromDB();

    virtual int Do(void* pData);
    virtual int CallBack(int iRet);

public:
    CDBCtrl* pstMainCtrl;
    CReqSelectData stReq;
    CAnsSelectData stAns;

private:
    CEnpNetHead m_stHead;
    CTMsgHead m_stMsgHead;

    bool _bHasOtherData;    //还有其他数据
    int _iFrom;             //主要用于批量取数据的时候标识当前取到的位置

    static char szBuf[CTMsgHead::EMAX_MSGLEN];

    int BuildSql(CCmdSQL* pstCmd);
    int HandleResult(CCmdSQL& stCmd);
    int SendSql();
    int AnsResult(int iRet);
    int AnsClients(int iRet);
};

#endif
